
package system.base;

import framework.core.*;
import system.SelectManager;
import system.data.*;
/*
    Author    :Jackey
    CreateTime:2008-02-19 14:11:28
*/
public class GWPublicMenuSrv extends IHandler
{   
    public GWPublicMenuSrv() 
    {
        super();
    }
    
    public void doAction(DBConnection con,SrvContext context,ILoginContext loginContext) throws Exception
    {
        String action_code = context.getActionCode();
        String pathReport = "/system/report/";
        String pathBase = "/system/base/";
        
        
        
        //报表菜单 start
        //到压库产品进销存报表
        if(action_code.equalsIgnoreCase("listReportYKProduct"))
        {
            context.setNextUrl(pathReport + "ReportYKProduct.jsp");
            return;
        }
        //到领用报表
        if(action_code.equalsIgnoreCase("listReportCustomer"))
        {
            context.setNextUrl(pathReport + "ReportCustomer.jsp");
            return;
        }
        //到压库产品进销存资金汇总月报
        if(action_code.equalsIgnoreCase("listReportYKProductMonth"))
        {
            context.setNextUrl(pathReport + "ReportYKProductMonth.jsp");
            return;
        }  
        //压库产品分类月进出明细
        if(action_code.equalsIgnoreCase("listReportYKProductMonthList"))
        {
            context.setNextUrl(pathReport + "ReportYKProductMonthList.jsp");
            return;
        }   
        //到压库产品应付款月报
        if(action_code.equalsIgnoreCase("listReportYKMoneyMonth"))
        {
            context.setNextUrl(pathReport + "ReportYKMoneyMonth.jsp");
            return;
        }        
        //到买断产品资金进出累计汇总
        if(action_code.equalsIgnoreCase("listReportMDMoneyInout"))
        {
            context.setNextUrl(pathReport + "ReportMDMoneyInout.jsp");
            return;
        }
      //到合并库收料清单
        if(action_code.equalsIgnoreCase("listReportCustomerInList"))
        {
            context.setNextUrl(pathReport + "ReportCustomerInList.jsp");
            return;
        }
        //到买断产品资金进出累计汇总
        if(action_code.equalsIgnoreCase("listReportMDWCMoneyInout"))
        {
            context.setNextUrl(pathReport + "ReportMDWCMoneyInout.jsp");
            return;
        }
        /** 新报表查询逻辑添加的页面***************/
        //1------9
        if(action_code.equalsIgnoreCase("listReportYKProductNew"))
        {
            context.setNextUrl(pathReport + "ReportYKProductNew.jsp");
            return;
        }
        if(action_code.equalsIgnoreCase("listReportYKProductNew2"))
        {  
        	String jspName="ReportYKProductNew2.jsp";
    	    doWarehouseList(con, context, loginContext, pathReport, jspName);

            return;
        }
        //3------10
        if(action_code.equalsIgnoreCase("listReportYKProductMonthNew"))
        {
            context.setNextUrl(pathReport + "ReportYKProductMonthNew.jsp");
            return;
        }
        //5------11
        if(action_code.equalsIgnoreCase("listReportMDMoneyInoutNew"))
        {
            context.setNextUrl(pathReport + "ReportMDMoneyInoutNew.jsp");
            return;
        }
        //7-----12
        if(action_code.equalsIgnoreCase("listReportYKProductMonthListNew"))
        {
            context.setNextUrl(pathReport + "ReportYKProductMonthListNew.jsp");
            return;
        }
        //8-----13
        if(action_code.equalsIgnoreCase("listReportMDWCMoneyInoutNew"))
        {
            context.setNextUrl(pathReport + "ReportMDWCMoneyInoutNew.jsp");
            return;
        }
        //14
        if(action_code.equalsIgnoreCase("listReportAllWarehouseMoneyMonthSum"))
        {
            context.setNextUrl(pathReport + "ReportAllWarehouseMoneyMonthSum.jsp");
            return;
        }
        //到买断进销存页面
        if(action_code.equalsIgnoreCase("listReportMDProduct")){
            context.setNextUrl(pathReport+"ReportMDProduct.jsp");
            return ;
        }
       /*******************月结******************/

        //到产品进销存（月结）页面
        if(action_code.equalsIgnoreCase("listReportProductMS")){
            search(con, context);
            context.setNextUrl(pathReport+"ReportProductMS.jsp");
            return ;
        }
        if(action_code.equalsIgnoreCase("listReportProductMS2")){
            search(con, context);

            doWarehouseList(con, context, loginContext, pathReport, "ReportProductMS2.jsp");

            return ;
        }
        //到产品外修进销存（月结）页面
        if(action_code.equalsIgnoreCase("listReportProductRepair")){
            search(con, context);
            context.setNextUrl(pathReport+"ReportProductRepair.jsp");
            return ;
        }
        //到产品外修进销存（月结）页面
        if(action_code.equalsIgnoreCase("listReportRepair")){
            search(con, context);
            context.setNextUrl(pathReport+"ReportRepair.jsp");
            return ;
        }
        //到领用报表(月结)
        if(action_code.equalsIgnoreCase("listReportCustomerMS"))
        {
            context.setNextUrl(pathReport + "ReportCustomerMS.jsp");
            return;
        }
        //产品进、销、存资金汇总报表(产品分类)(月结)
        if(action_code.equalsIgnoreCase("listReportMoneyInoutProductCategoryMS"))
        {
            search(con, context);
            context.setNextUrl(pathReport + "ReportMoneyInoutProductCategoryMS.jsp");
            return;
        }      
        //产品进、销、存资金汇总报表（仓库分类）(月结)
        if(action_code.equalsIgnoreCase("listReportMoneyInoutWarehouseCategoryMS"))
        {
            search(con, context);
            context.setNextUrl(pathReport + "ReportMoneyInoutWarehouseCategoryMS.jsp");
            return;
        }      
   
        //到压库产品应付款月报(月结)
        if(action_code.equalsIgnoreCase("listReportYKMoneyMonthMS"))
        {
            context.setNextUrl(pathReport + "ReportYKMoneyMonthMS.jsp");
            return;
        }   
           //到空调报表页面
        if(action_code.equalsIgnoreCase("listReportAirProduct")){
            context.setNextUrl(pathReport+"ReportAirProduct.jsp");
            return ;
        }
        
        //到产品进销存供应商分类报表页面
        if(action_code.equalsIgnoreCase("listReportProduct")){
            context.setNextUrl(pathReport+"ReportProduct.jsp");
            return ;
        }
        //供应商应付报表
       if(action_code.equalsIgnoreCase("listProviderProduct")){
            context.setNextUrl(pathReport+"ReportProvider.jsp");
            return ;
        }
       //供应商应付报表2
       if(action_code.equalsIgnoreCase("listProviderProduct2")){
    	   doWarehouseList(con, context, loginContext, pathReport, "ReportProvider2.jsp");

            return ;
        }
       //供应商结算分类明细报表
       if(action_code.equalsIgnoreCase("listProviderProductType")){
            context.setNextUrl(pathReport+"ReportProviderProductType.jsp");
            return ;
        }
       
       //供应商结算分类总汇报表
       if(action_code.equalsIgnoreCase("listProviderProductTypeAll")){
            context.setNextUrl(pathReport+"ReportProviderProductTypAll.jsp");
            return ;
        }
       
       //供应商营运公司应付报表
       if(action_code.equalsIgnoreCase("listProviderCustomer")){
    	   context.setNextUrl(pathReport + "ReportProviderCustomer.jsp");
           return;
        }
     //开票信息导出报表
       if(action_code.equalsIgnoreCase("listProductTaxMessage")){
    	   doWarehouseList(con, context, loginContext, pathReport, "ReportTaxMessage.jsp");
    	
           return;
        }
       if(action_code.equalsIgnoreCase("listSafeStorage")){
    	   context.setNextUrl(pathReport + "ReportSafeStorage.jsp");
           return;
        } 
       if(action_code.equalsIgnoreCase("bigBusNavigation")){
    	   context.setNextUrl(pathReport + "ReportBigBusTotal.jsp");
           return;
        }
       if(action_code.equalsIgnoreCase("busBigScreanAll")){
    	   context.setNextUrl(pathReport + "BigScreanAll.jsp");
           return;
        }
        
        Logger.throwException("GWPublicMenuSrv","unknown action_code="+action_code);
    }

	public void doWarehouseList(DBConnection con, SrvContext context,
			ILoginContext loginContext, String pathReport, String jspName)
			throws Exception {

		WarehouseProductViewSearchEvent event = (WarehouseProductViewSearchEvent)SearchEvent.fromForm(context,WarehouseProductViewSearchEvent.class);
		String []warehouseCodes = null;

		String[] warehouseTreeCodes ;



			warehouseTreeCodes = new String[]{loginContext.getLoginWarehouseCode()}; 
		    warehouseCodes = new String[]{loginContext.getLoginWarehouseCode()}; 
		    ObjectList warehouseList =Warehouse.fetchWarehousesList(con, loginContext.getLoginWarehouseCode());
		event.setWarehouseTreeCodes(warehouseTreeCodes);
		event.setWarehouseCodes(warehouseCodes);
		event.setWarehouseCodeUser(ConstDefine.getWildCard(loginContext.getLoginWarehouseCode()));
		context.setSessionValue("WarehouseProductViewSearchEvent",event);
		context.setSessionValue("WarehouseListDetail",warehouseList);
		
		context.setNextUrl(pathReport+jspName);
	}   
    private void search(DBConnection con,SrvContext context)throws Exception{
        MonthStorageSearchEvent event = (MonthStorageSearchEvent)SearchEvent.fromForm(context,MonthStorageSearchEvent.class);
        String warehouse_code;
        try {
            warehouse_code = context.getString("warehouseCode").trim();
        } catch (RuntimeException e) {
            warehouse_code ="";
        }
        if(warehouse_code!=null&&!warehouse_code.equals("")){
            event.setWarehouseCodes(new String []{warehouse_code});
        }
        context.setSessionValue("MonthStorageSearchEvent",event);;
    }

}